<?php 

//////////////////////////////////////////////////////////////////////////////////////////////////////
//										DMI V3 Fiche V0.0.1 beta1									//
//																									//
//   25/06/11 (Filament) : création de la pagee														//
//																									//
//   Cette page doit retourner des fiches d'informations pour les  infos bulle qtip					//
//																									//
//	Cette page utilise le minimum de phpBB3 afin d'avoir des requêtes AJAX plus légères				//
//																									//
//////////////////////////////////////////////////////////////////////////////////////////////////////
//								APPELS NECESSAIRES SUR TOUTES LES PAGES								//


//Chemin du répertoire courant à la racine
$rep ="../";

//design via phpBB3
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : $rep.'phpBB3/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
require($phpbb_root_path . 'includes/functions_user.' . $phpEx);
require($phpbb_root_path . 'includes/functions_module.' . $phpEx);

//Informations sur le membre :
$user->session_begin();
$auth->acl($user->data);

//Mise en page
$user->setup('viewforum');

//Déclarations essentielles pour le traitement de la page :
$bbcode_bitfield = '';
$bbcode = new bbcode(base64_encode($bbcode_bitfield));

//////////////////////////////////////////////////////////////////////////////////////////////////////
//										Requêtes PHP												//

switch(request_var('type', '0')) {
	case 1 :
		$informations = "SELECT
							f.id_film as identifiant
							, f.titre as titre
							, f.poster as image
							, f.description as description
							, f.description_bitfield as desc_bit
							, f.description_uid as desc_uid
						FROM
							" . FILM_TABLE . " f
							, " . ABBREVIATION_TABLE . " a
							, " . DICTIONNAIRE_TABLE . " d
						WHERE
								a.id_abbreviation = '".request_var("id_abb", '0')."'
							AND
								d.id_mot = a.id_mot
							AND
								f.id_film = d.id_lien";
		$cat = 'films';
		break;
	case 2 :
		$informations = "SELECT
							p.id_personnalite as identifiant
							, GROUP_CONCAT(p.prenom, '  ', p.nom) as titre
							, p.photo as image
							, p.description as description
							, p.description_bitfield as desc_bit
							, p.description_uid as desc_uid
						FROM
							" . PERSONNALITE_TABLE . " p
							, " . ABBREVIATION_TABLE . " a
							, " . DICTIONNAIRE_TABLE . " d
						WHERE
								a.id_abbreviation = '".request_var("id_abb", '0')."'
							AND
								d.id_mot = a.id_mot
							AND
								p.id_personnalite = d.id_lien";
		$cat = 'personnalites';
		break;	
	case 3 :
		$informations = "SELECT
							at.id_attraction as identifiant
							, at.nom as titre
							, at.photo as image
							, at.description as description
							, at.description_bitfield as desc_bit
							, at.description_uid as desc_uid
						FROM
							" . ATTRACTION_TABLE . " at
							, " . ABBREVIATION_TABLE . " a
							, " . DICTIONNAIRE_TABLE . " d
						WHERE
								a.id_abbreviation = '".request_var("id_abb", '0')."'
							AND
								d.id_mot = a.id_mot
							AND
								at.id_attraction = d.id_lien";
		$cat = 'attractions';
		break;
	case 4 :
		$informations = "SELECT
							p.id_parc as identifiant
							, p.nom as titre
							, p.photo as image
							, p.description as description
							, p.description_bitfield as desc_bit
							, p.description_uid as desc_uid
						FROM
							" . PARC_TABLE . " p
							, " . ABBREVIATION_TABLE . " a
							, " . DICTIONNAIRE_TABLE . " d
						WHERE
								a.id_abbreviation = '".request_var("id_abb", '0')."'
							AND
								d.id_mot = a.id_mot
							AND
								p.id_parc = d.id_lien";
		$cat = 'parcs';
		break;
	case 5 :
		$informations = "SELECT
							di.id_produit as identifiant
							, di.nom as titre
							, di.photo as image
							, di.description as description
							, di.description_bitfield as desc_bit
							, di.description_uid as desc_uid
						FROM
							" . DISNEYANA_TABLE . " di
							, " . ABBREVIATION_TABLE . " a
							, " . DICTIONNAIRE_TABLE . " d
						WHERE
								a.id_abbreviation = '".request_var("id_abb", '0')."'
							AND
								d.id_mot = a.id_mot
							AND
								di.id_produit = d.id_lien";
		$cat = 'disneyana';
		break;
}
$result = $db->sql_query_limit($informations, 1);
$infos = $db->sql_fetchrow($result);



//On encode la description
$bbcode = new bbcode(base64_encode($infos['desc_bitfield']));
$bbcode->bbcode_second_pass($infos['description'], $infos['des_uid'], $infos['desc_bitfield']);
$description = bbcode_nl2br($infos['description']);
$description = smiley_text($description);

//////////////////////////////////////////////////////////////////////////////////////////////////////
//						Envoi au template															//

page_header('Fiche');
$template->assign_vars(array(
	'CAT'			=> $cat,
	'IMAGE'			=> $infos['image'],
	'DESCRIPTION'	=> $description,
	'TITRE'			=> $infos['titre']
));
$template->set_filenames(array(
   'body' => 'dmi/fiche.html',
      )
);
page_footer();
?>
